package org.kernelab.basis;

/**
 * The Reducer interface is applied to the operation of reducing a Collection.
 * 
 * @author Dilly King
 * 
 * @param <E>
 *            The generic type of the elements to be reduced in the Collection.
 * @param <R>
 *            The generic type of the reduce result.
 */
public interface Reducer<E, R>
{
	/**
	 * To reduce the element in a certain Collection into the reduction result.
	 * 
	 * @param r
	 *            A former result of reduction. Result would be null when first
	 *            execute the reduce operation.
	 * @param e
	 *            An element in a certain Collection.
	 * @return The result of is reduce operation.
	 * @see Tools#reduce(java.util.Collection, Reducer)
	 */
	public R reduce(R r, E e);
}
